package com.sssoft.Yundian.activity;

import com.sssoft.Yundian.R;
import com.sssoft.Yundian.R.layout;
import com.sssoft.Yundian.Dao.DataDao;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity {
	private EditText username1;
	private EditText password1;
	private Button button1;
	private TextView button2;
	private TextView button3;
	private DataDao dao;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_login);
		Button button1 = (Button) findViewById(R.id.button1);
		TextView button2 = (TextView) findViewById(R.id.button2);
		TextView button3 = (TextView) findViewById(R.id.button3);

		username1 = (EditText) findViewById(R.id.et_Text);
		password1 = (EditText) findViewById(R.id.et_Password);
		dao = new DataDao(this);
		//��¼
		button1.setOnClickListener(new Button.OnClickListener() {

			@Override
			public void onClick(View view) {
				String username = username1.getText().toString();
				String password = password1.getText().toString();
				if (!dao.NameId(username, password)) {
					Toast.makeText(LoginActivity.this, "帐号或密码错误", Toast.LENGTH_SHORT).show();
				} else {
					Toast.makeText(LoginActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
					 Intent intent = new Intent(LoginActivity.this, MainActivity.class);
					 startActivity(intent);
					 finish();
				}
			}

		});
		
		button2.setOnClickListener(new Button.OnClickListener() {
			@Override
			public void onClick(View view) {
				 Intent intent = new Intent(LoginActivity.this, SigninActivity.class);
				 startActivity(intent);
			}
		});
		
		button3.setOnClickListener(new Button.OnClickListener() {
			@Override
			public void onClick(View view) {
				 Intent intent = new Intent(LoginActivity.this, ForgetActivity.class);
				 startActivity(intent);
			}
		});

	}
}
